package com.norman.sorry.core.moves;

import java.util.Collection;
import java.util.Map;

import com.norman.sorry.core.pieces.IPiece;
import com.norman.sorry.core.tiles.ILinkedTile;

/**
 * A helper class for creating a concrete version of a move.
 * 
 * @author Brian Norman
 * @version 0.0.1 beta
 * @since 0.0.1 beta
 */
public abstract class AbstractMove implements IMove {

   /**
    * A map of the pieces and where they are located.
    */
   protected Map<IPiece, ILinkedTile> moves;

   /**
    * Creates a new move that involves the given pieces and their locations.
    * 
    * @param moves
    *           a map of pieces involved in the move and their location.
    */
   public AbstractMove(Map<IPiece, ILinkedTile> moves) {
      this.moves = moves;
   }

   /**
    * {@inheritDoc}
    * 
    * @see com.norman.sorry.core.moves.IMove#getTile(IPiece)
    */
   @Override
   public ILinkedTile getTile(IPiece piece) {
      return moves.get(piece);
   }

   /**
    * {@inheritDoc}
    * 
    * @see com.norman.sorry.core.moves.IMove#getPieces()
    */
   @Override
   public Collection<IPiece> getPieces() {
      return moves.keySet();
   }

}
